set shell=/bin/bash
set nocompatible
set number
set hlsearch
set incsearch
set cursorline
set laststatus=2
set encoding=utf-8
set backspace=2
let g:Powerline_symbols='fancy'
set ruler
syntax enable
syntax on
set background=dark
set t_Co=256
let g:solarized_termcolors=256
" colorscheme solarized
colorscheme molokai
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'Lokaltog/vim-powerline'
Plugin 'octol/vim-cpp-enhanced-highlight'
Plugin 'majutsushi/tagbar'
Plugin 'scrooloose/nerdtree'
Plugin 'derekwyatt/vim-fswitch'
Plugin 'tomasr/molokai'
Plugin 'flazz/vim-colorschemes'
Plugin 'yegappan/grep'
Plugin 'dyng/ctrlsf.vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'Valloric/YouCompleteMe'
Plugin 'kien/ctrlp.vim'
Plugin 'gilligan/vim-lldb'
call vundle#end()
filetype plugin indent on
set tabstop=4
set shiftwidth=4
set softtabstop=4
set foldmethod=syntax
set nofoldenable

" 縮進
" nmap <tab> V>
" nmap <s-tab> V<
" vmap <tab> >gv
" vmap <s-tab> <gv

" NERDTree插件配置
au VimEnter * NERDTree
map <F2> :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.o','\.swp']
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
nmap <C-o> :FSHere<cr>

" tagbar配置
let tagbar_right=1
nnoremap <Leader>p :TagbarToggle<CR>
let tagbar_width=32
let g:tagbar_compact=1
let g:tagbar_type_cpp = {
    \ 'kinds' : [
         \ 'c:classes:0:1',
         \ 'd:macros:0:1',
         \ 'e:enumerators:0:0', 
         \ 'f:functions:0:1',
         \ 'g:enumeration:0:1',
         \ 'l:local:0:1',
         \ 'm:members:0:1',
         \ 'n:namespaces:0:1',
         \ 'p:functions_prototypes:0:1',
         \ 's:structs:0:1',
         \ 't:typedefs:0:1',
         \ 'u:unions:0:1',
         \ 'v:global:0:1',
         \ 'x:external:0:1'
     \ ],
     \ 'sro'        : '::',
     \ 'kind2scope' : {
         \ 'g' : 'enum',
         \ 'n' : 'namespace',
         \ 'c' : 'class',
         \ 's' : 'struct',
         \ 'u' : 'union'
     \ },
     \ 'scope2kind' : {
         \ 'enum'      : 'g',
         \ 'namespace' : 'n',
         \ 'class'     : 'c',
         \ 'struct'    : 's',
         \ 'union'     : 'u'
     \ }
	 \ }

" ctrlsf配置
nnoremap <C-F> :CtrlSF<CR>
let g:ctrlsf_auto_focus={"at":"start"}
let g:ctrlsf_default_root='project'
let g:ctrlsf_default_view_mode='normal'
let g:ctrlsf_search_mode = 'async'
let g:ctrlsf_winsize = '30%'


" nerdcomment配置
let g:NERDSpaceDelims = 1
let g:NERDCustomDelimiters = { 'cpp': { 'left': '//' },'hpp':{'left':'//'},'h':{'left':'//'} }


" YouCompleteMe
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
" YCM 补全菜单配色
" 补全功能在注释中同样有效
let g:ycm_complete_in_comments=1
" 允许 vim 加载 .ycm_extra_conf.py 文件，不再提示
let g:ycm_confirm_extra_conf=0
" 开启 YCM 标签补全引擎
let g:ycm_collect_identifiers_from_tags_files=1
" 引入 C++ 标准库tags
set tags+=/data/misc/software/misc./vim/stdcpp.tags
" YCM 集成 OmniCppComplete 补全引擎，设置其快捷键
" inoremap <leader>; <C-x><C-o>
" 补全内容不以分割子窗口形式出现，只显示补全列表
set completeopt-=preview
" 从第一个键入字符就开始罗列匹配项
let g:ycm_min_num_of_chars_for_completion=1
" 禁止缓存匹配项，每次都重新生成匹配项
let g:ycm_cache_omnifunc=0
" 语法关键字补全			
let g:ycm_seed_identifiers_with_syntax=1
" CtrlP
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pb.cc,*.pb.h
